home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Applications / Text / Doc Makers / WEBSs / WEBSs Books / Tutorial / Texts / 5.Fifth < prev    next >
Encoding:
Text File  |  1992-10-23  |  3.9 KB  |  73 lines  |  [TEXT/WEBS]

  1. Scripts
  2.  
  3. Now we come to a very interesting part of WEBSs, the scripting facilities. 
  4.  
  5. Scripts are small programs that allow you to :
  6.  
  7. (1) automate series of actions,
  8.  
  9. (2) modify the behaviour of the components of an Electronic Book (especially documents and links).
  10.  
  11. We will now try an example of the first possibility:
  12.  
  13. 1. Make sure that several documents are open. If this is not the case, open a few documents with the Open command from the File Menu.
  14.  
  15. 2.  Choose the Execute Other Script command from the Script menu, select the item named "CloseAll w/o Fifth and Demo" and click the Execute button.....
  16.  
  17. You have actually invoked your first unbound script, which has closed all open documents except the documents named "5.Fifth" and "Demo.Table". Unbound scripts allow you to regroup a set of actions into a single command and to play it back at will in different contexts. As you have seen, you can do very useful things with such scripts.
  18.  
  19. Scripts are created in the Script Browser. To make it appear, choose the Show Script Browser command from the Script menu. Move it to the top left corner and resize it so that you can still read this document. In the pop-up menu on the left, you can select among different kinds of scripts, including unbound scripts. If you select the script named "Close All w/o Fifth and Demo" in the right pane, you can see the actions executed by the script in the lower pane.
  20.  
  21. We will now look at an example of the second kind of scripts :
  22.  
  23. 1. Follow this link.                                         
  24. Nothing special happens.
  25.  
  26. 2. Choose the Automatic Script Execution command from the Script menu. It should now be checked.
  27.  
  28. 3. Follow the same link as before. 
  29. Now something has happened!!!
  30.  
  31. This is the second kind of scripts, triggered scripts. You can decide that a script will be automatically executed when a certain action is performed by a specific object, like the opening of a document. 
  32.  
  33. In this example, a script was attached to the Follow action of the link named "Demo Link".
  34.  
  35.  You can look at this script in the script browser by selecting the Objects item in the pop-up menu on the left. Click on the item named "Demo Link" in the left pane, and a script called "Hello" will appear in the right pane. If you click on it, its contents will be displayed in the lower pane. 
  36.  
  37. (You can also verify the name of the link to which the script is attached by selecting the block marker and choosing the Get Link Info command from the WEBSs menu).
  38.  
  39. Triggered scripts enable you to affect the way an object reacts to an action. A triggered script can be attached not only to an individual object, but also to all objects in a specific set, or to all objects of a certain class.
  40.  
  41. While you cannot modify modify the script "Hello", because it belongs to the author web (thus the read-only icon), you can duplicate it and modify the copy. Do the following :
  42.  
  43. 1. Select the script "Hello".
  44.  
  45. 2. Choose the Duplicate Script command from the Script menu. A copy of the script "Hello" is made with the name "Hello Copy" and is automatically selected.
  46.  
  47. 3. In your new script, replace the line
  48.  
  49.   Message('Hello ' )
  50.   
  51. with
  52.   
  53.   Message('Hello ' + UserName)
  54.  
  55. (Use copy/paste if you want to be sure that everything is correct)
  56.  
  57. 3. Choose the Compile Script command from the Script menu. 
  58.  
  59. 4. Enable the script by clicking on its left where the check marks are displayed (the cursor will change to a ).
  60.  
  61. 5. Test the modified script by following the same link as before (you will find it at the end of this document). Two dialog boxes will appear successively, since two scripts are triggered (yours and the author's one).
  62.  
  63. As you see, you can modify existing scripts without knowing all the subtleties of script writing. 
  64.  
  65. Note also that the execution of a script can be aborted by pressing -. 
  66.  
  67. When you are finished with scripts, use the "Next Node" command of the Browser menu to continue this tutorial with document "Sixth".
  68.  
  69.  
  70.  
  71.  
  72. End of link. Follow it again to go back.
  73.